unit uRel_imoveis_loca;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, StdCtrls, dxCore, dxButton, ExtCtrls, rpcompobase,
  rpvclreport;

type
  TfRel_imoveis_loca = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Panel2: TPanel;
    dxButton1: TdxButton;
    dxButton2: TdxButton;
    edCodCliente: TEdit;
    SpeedButton1: TSpeedButton;
    Label3: TLabel;
    RadioGroup1: TRadioGroup;
    Edit1: TEdit;
    VCLReport1: TVCLReport;
    dxButton3: TdxButton;
    RadioGroup2: TRadioGroup;
    VCLReport2: TVCLReport;
    procedure SpeedButton1Click(Sender: TObject);
    procedure dxButton1Click(Sender: TObject);
    procedure dxButton3Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure dxButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fRel_imoveis_loca: TfRel_imoveis_loca;

implementation

uses UDM, udmAcesso, uProcurar;

{$R *.dfm}

procedure TfRel_imoveis_loca.SpeedButton1Click(Sender: TObject);
begin
  FProcurar:=TFProcurar.Create(Self,dm.proc_proprietario);
  try
   FProcurar.BtnProcurar.Click;
   fProcurar.EvDBFind1.DataField := 'NOME_PROPRIETARIO';
   if FProcurar.ShowModal=mrOK then
  begin
   edCodCliente.Text := dm.proc_proprietarioNOME_PROPRIETARIO.AsString;
   Edit1.Text := IntToStr(dm.proc_proprietarioCOD_PROPRIETARIO.AsInteger);
  end;
  finally
   DM.proc_proprietario.Close;
   FProcurar.Free;
  end;
end;

procedure TfRel_imoveis_loca.dxButton1Click(Sender: TObject);
begin

 if RadioGroup2.ItemIndex = 0 then
 begin
  VCLReport1.Filename := str_relatorio + 'rel_imoveis_loc.rep';
  if RadioGroup1.ItemIndex = 0 then
    VCLReport1.Report.Params.ParamByName('PCOD').Value
       := 'S';
  if RadioGroup1.ItemIndex = 1 then
    VCLReport1.Report.Params.ParamByName('PCOD').Value
       := 'N';
  if RadioGroup1.ItemIndex = 2 then
    VCLReport1.Report.Params.ParamByName('PCOD').Value
       := 't';
  if Edit1.Text = '' then
    VCLReport1.Report.Params.ParamByName('PPRO').Value
       := 9999999
  else
    VCLReport1.Report.Params.ParamByName('PPRO').Value
       := StrToInt(Edit1.Text);
    VCLReport1.Title := VCLReport1.FileName;   
    VCLReport1.Execute;
 end;

 if RadioGroup2.ItemIndex = 1 then
 begin
  VCLReport2.Filename := str_relatorio + 'rel_imoveis_venda.rep';
  if RadioGroup1.ItemIndex = 0 then
    VCLReport2.Report.Params.ParamByName('PCOD').Value
       := 'S';
  if RadioGroup1.ItemIndex = 1 then
    VCLReport2.Report.Params.ParamByName('PCOD').Value
       := 'N';
  if RadioGroup1.ItemIndex = 2 then
    VCLReport2.Report.Params.ParamByName('PCOD').Value
       := 't';
  if Edit1.Text = '' then
    VCLReport2.Report.Params.ParamByName('PPRO').Value
       := 9999999
  else
    VCLReport2.Report.Params.ParamByName('PPRO').Value
       := StrToInt(Edit1.Text);
    VCLReport2.Execute;
 end;

end;

procedure TfRel_imoveis_loca.dxButton3Click(Sender: TObject);
begin
  Edit1.Text := '';
  edCodCliente.Text := '';
end;

procedure TfRel_imoveis_loca.FormShow(Sender: TObject);
begin
 RadioGroup1.ItemIndex := 0;
 Edit1.Text := '';
 edCodCliente.Text := '';
end;

procedure TfRel_imoveis_loca.dxButton2Click(Sender: TObject);
begin
  close;
end;

end.
